package com.yang.system.domain.orgMng.org;

import com.yang.system.common.framework.AuditableEntity;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;

@Getter  // 为所有字段生成 getter 方法
public class Org extends AuditableEntity {
    private Long id;
    @Setter
    private Long tenantId;

    @Setter
    private Long superiorId;
    @Setter
    private String orgTypeCode;

    @Setter
    private Long leaderId;

    @Setter
    private String name;

    @Setter
    private OrgStatus status; // 使用枚举类型



    public Org() {
        status = OrgStatus.EFFECTIVE;  // 组织的初始状态默认为有效
    }

       public Org(Long tenantId, String orgTypeCode, LocalDateTime createdAt, Long createdBy) {
       super(createdAt, createdBy); // 调用父类构造方法初始化审计字段
       this.tenantId = tenantId;
       this.orgTypeCode = orgTypeCode;
   }


    //Org 自己管理自己的状态
    public void cancel() {
        this.status = OrgStatus.CANCELLED;
    }

    public boolean isEffective() {
        return status.equals(OrgStatus.EFFECTIVE);
    }
}
